﻿using System.Windows;
using Dsl.Ped.Desktop.Resources;
using Dsl.Ped.Editor;

namespace Dsl.Ped.Desktop.Modules.Editor
{
    /// <summary>
    /// This is the class representing a main module of the desktop editor.
    /// It wraps the universal <see cref="DslPedEditor"/> appropriately.
    /// </summary>
    public class EditorModule : IModule
    {
        /// <summary>
        /// Instance of the <see cref="DslPedEditor"/> wrapped inside this module
        /// </summary>
        private DslPedEditor dslPedEditor = new DslPedEditor(ApplicationResources.Instance.AvalableAddIns);

        /// <summary>
        /// Controller of the editor to properly handle all interactions with the module
        /// </summary>
        private EditorController editorController;

        /// <summary>
        /// Instantiates new <see cref="EditorModule"/>
        /// </summary>
        public EditorModule()
        {
            editorController = new EditorController(dslPedEditor);
            editorController.Start(ApplicationResources.Instance.Messenger);
        }

        /// <summary>
        /// Gets the view of a module
        /// </summary>
        public FrameworkElement View
        {
            get
            {
                // View depends on the wrapped editor instance
                return new EditorView(dslPedEditor);
            }
        }

        /// <summary>
        /// Gets the name of the module. The name is used for the opening/closing
        /// the module via Ribbon.
        /// </summary>
        public string Name
        {
            get
            {
                return "Editor";
            }
        }

        /// <summary>
        /// Gets the title of the module. The name is displayed in the
        /// Ribbon bar of the application.
        /// </summary>
        public string Title
        {
            get
            {
                return DesktopLang.CodeEditor;
            }
        }

        /// <summary>
        /// Gets the uri representing the editor in the Ribbon bar icon.
        /// </summary>
        public string ImageUri
        {
            get
            {
                return "Resources/Images/editor.png";
            }
        }
    }
}
